package edu.henu.personnel.dao;

import edu.henu.personnel.entity.DownLoadFile;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DownloadFileDao {

    // 根据fcid查询所在目录所有的下载文件
    @Select("select * from t_file where fcid = #{fcid}")
    List<DownLoadFile> findDownloadFileByCid(@Param("fcid") Integer fcid);

    // 添加新的文件
    @Insert("insert into t_file " +
            "(fcid, fname, fpath, fdate) " +
            "values " +
            "(#{fcid}, #{fname}, #{fpath}, #{fdate})")
    int insertFile(DownLoadFile downLoadFile);

    // 根据fid删除指定的文件
    @Delete("delete from t_file where fid = #{fid}")
    int removeFile(Integer fid);
}
